﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Quizz.DataRepository.Models;
using Quizz.Service.Services;
using Quizz.QuizzProjectService.Models;

namespace Quizz.QuizzProjectService
{
    public partial class QuizzProjectService
    {
        public Question QuestionGetById(long id)
        {
            using(var service = new QuestionService())
            {
                return service.GetById(id);
            }
        }

        public IList<Question> QuestionGetAllForUser(long userId, string orderCols)
        {
            using (var service = new QuestionService())
            {
                return service.GetAllForUser(userId, orderCols).ToList();
            }
        }

        public IList<Question> QuestionGetAllForUserPage(long userId, int page, int count, string orderCols)
        {
            using (var service = new QuestionService())
            {
                return service.GetAllForUserPage(userId, page, count, orderCols).ToList();
            }
        }

        public void QuestionInsert(Question question)
        {
            using (var service = new QuestionService())
            {
                service.Insert(question);
            }
        }

        public void QuestionUpdate(Question question)
        {
            using (var service = new QuestionService())
            {
                service.Update(question);
            }
        }

        public bool QuestionDelete(long id)
        {
            using (var service = new QuestionService())
            {
                return service.Delete(id);
            }
        }

        public QuestionPageResult QuestionGetPage(long userId, long subjectId, int page, int count, string orderCol)
        {
            using (var service = new QuestionService())
            {
                var result = new QuestionPageResult();

                int sumCount = 0;
                result.Questions = service.GetQuestionPage(userId, subjectId, page, count, orderCol, ref sumCount);
                result.ItemCount = sumCount;

                return result;
            }
        }
    }
}